#include "parsetree.h"
#include <iostream>
#include "symboltable.h"
#include "codegenerator.h"

bool Thinder::ParseTree::Identifier::operator<(const Identifier &other) const
{
    return this->identifier < other.identifier;
}

bool Thinder::ParseTree::Identifier::operator==(const Identifier &other) const
{
    return this->identifier == other.identifier;
}

bool Thinder::ParseTree::Identifier::operator!=(const Identifier &other) const
{
    return this->identifier != other.identifier;
}

bool Thinder::ParseTree::Type::operator==(const Type &other) const
{
    // TODO Array
    if (typeType == PrimitiveType && other.typeType == PrimitiveType)
    {
        return primitiveType == other.primitiveType;
    }
    
    if (typeType == UserType && other.typeType == UserType)
    {
        return userType == other.userType;
    }
    
    return false;
}

bool Thinder::ParseTree::Type::operator!=(const Type &other) const
{
    return !(*this == other);
}

Thinder::ParseTree::Type Thinder::ParseTree::Type::Unknown()
{
    Type type;
    type.typeType = Type::UserType;
    type.userType = toName("Thinder.Prim.object");
    return type;
}


Thinder::ParseTree::Identifier::Identifier()
{
}

Thinder::ParseTree::Identifier::Identifier(string ident)
{
    this->identifier = ident;
}

